package org.noote.libs.skeleton;

import java.util.ArrayList;

import android.opengl.Matrix;

public class Skeleton {

	private ArrayList<Bone> _bones = new ArrayList<Bone>();
	
	public Skeleton()
	{
	}
	
	public Bone newBone()
	{
		Bone new_bone = new Bone();
		if(addBone(new_bone))
			return new_bone;
		return null;
	}

	public boolean addBone(Bone bone)
	{
		return _bones.add(bone);
	}
	
	public ArrayList<Bone> getBones() {
		return _bones;
	}
	
	public void update()
	{
		float inMatrix[] = new float[16];
		Matrix.setIdentityM(inMatrix, 0);

		for(Bone bone : _bones)
		{
			// for all parents bones : calcul skeletal position :)
			if(bone._parent == null)
			{
				bone.update(inMatrix);
			}
		}
	}
}
